package com.study.shop.entity.common;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageInfo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class MyPage<T> {
    private int countId;
    // 当前页码
    private int current;
    private boolean hitCount;
    private int maxLimit;
    private boolean optimizeCountSql;
    private List<T> orders;
    // 总页数
    private int pages;
    // 记录
    private List<T> records;
    private int searchCount;
    // 每页大小
    private int size;
    // 总记录条数
    private int total;


    public MyPage(PageInfo<T> pageInfo) {
        this.current = pageInfo.getPageNum();
        this.pages = pageInfo.getPages();
        this.records = pageInfo.getList();
        this.size = pageInfo.getPageSize();
        this.total = Integer.parseInt(pageInfo.getTotal() + "");
    }
}
